package com.study.springcloud.impl;

import com.study.springcloud.mapper.GoodsMapper;
import com.study.springcloud.pojo.Goods;
import com.study.springcloud.serivce.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Chen Jie
 * @Date 2022/3/5 13:34
 * @Version 1.0
 */
@Service("goodsServiceImpl")
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public List<Goods> getAllGoods() {
        return goodsMapper.selectAllGoods();
    }

    @Override
    public Goods getGoodsById(Integer goodsId) {
        return goodsMapper.selectByPrimaryKey(goodsId);
    }

    @Override
    public int decrByStore(Integer goodsId, Integer buyNum) {
        return goodsMapper.updateByStore(goodsId, buyNum);
    }
}
